﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using BlueLotus7.ArchiveSystem.Interfaces;
using BlueLotus7.Common;

namespace BlueLotus7.ArchiveSystem.Common
{
    [DataContract]
    public class ArchivedBinaryArticle : ArchivedArticle, ICopyProperty<ArchivedArticle>
    {
        public string SourceUrl
        {
            get;
            set;
        }

        public string SourceName
        {
            get;
            set;
        }

        [DataMember]
        public byte[] BinaryData
        {
            get;
            set;
        }

        [DataMember]
        public string FileExetension
        {
            get;
            set;
        }

        [DataMember]
        public string MD5
        {
            get;
            set;
        }

        [DataMember]
        public int FileSize
        {
            get;
            set;
        }

        [DataMember]
        public string Description
        {
            get;
            set;
        }

        public bool HasData
        {
            get { return this.BinaryData == null; }
        }

        public virtual void CopyProperty(ArchivedBinaryArticle container, ArchivedBinaryArticle objectToCopy)
        {
            if (container != null && objectToCopy != null)
            {
                base.CopyProperty(container, objectToCopy);
                container.Owner = objectToCopy.Owner;
            }
        }
    }
}
